package demo.day11_CollectionAddpackage;

import java.util.Arrays;

/**
 * @Auther: hjy(lc))
 * @Date: 2022/8/1-08-01-10:21
 * @Description：demo.day11_CollectionAddpackage   Object 的toString方法
 */
public class toString_use {
    public static void main(String[] args) {
//        String s1 = "重地";
//        String s2 = "通话";
//        System.out.println(s1==s2);
//        System.out.println("重地".equals("通话"));
//        System.out.println(s2.hashCode());
        String[] arr = {"213","3dd","345","cse","we23","ase"};
        System.out.println(Arrays.toString(arr));
        change(arr,1,3);
        System.out.println(Arrays.toString(arr));
    }
    public static <T> void revanse(T[] arr){
        for (int i = 0; i < arr.length / 2; i++) {
            int j = arr.length-1-i;
            if(i >= j){
                break;
            }
            T temp = arr[i];
            arr[i] = arr[j];
            arr[j] = temp;
        }
    }
    public static <T> void change(T[] arr,int index1,int index2){
        if(index1<0 || index1 > arr.length-1 ||index2<0||index2>arr.length-1){
            throw new ArrayIndexOutOfBoundsException("数组越界，交换出错！");
        }
        T temp = arr[index1];
        arr[index1] = arr[index2];
        arr[index2] = temp;
    }
}
